package yuhuibear.poat.util;

import static org.junit.Assert.assertEquals;

import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

import yuhuibear.poat.util.sqlParse.SqlSentence;

public class FromClauseTest {

	@Test
	public void testToTableNames() {
		Set<String> expResult = new HashSet<String>();
		expResult.add("table_A");
		expResult.add("table_B");
		expResult.add("table_C");
		expResult.add("table_D");
		expResult.add("table_E");
		expResult.add("funFrom");
		String sql = "select * from "
				+ "table_A, "
				+ "table_B left join table_C as tB_j_tC on table_B.atr1=table_C.atr2 , "
				+ "table_C outer join table_D on table_C.atr = table_D.atr as tC_j_tD,"
				+ "table_E, funFrom(aaaaaaaaaa)";
		SqlSentence fc = new SqlSentence();
		for (char ch : sql.toCharArray()) {
			fc.pushChar(ch, false);
		}
		assertEquals(expResult, fc.getRefs());
	}

}
